package service.impl;

import dao.SmbmsUserDao;
import dao.impl.SmbmsUserDaoImpl;
import pojo.SmbmsUser;
import service.SmbmsUserService;
import utils.BaseDao;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class SmbmsUserServiceImpl implements SmbmsUserService {
    //dao层
    private SmbmsUserDao smbmsUserDao = new SmbmsUserDaoImpl();

    //登录功能
    @Override
    public SmbmsUser login(String userCode, String password) throws Exception {
        SmbmsUser smbmsUser = smbmsUserDao.queryUserByUserCode(userCode);
        if (null != smbmsUser) {
//通过密码进行判断
            System.out.println("password:"+password);
            System.out.println("smbmsUser.getUserPassword():"+smbmsUser.getUserPassword());
            if (!password.equals(smbmsUser.getUserPassword())) {
                smbmsUser = null;
            }
        }
        return smbmsUser;
    }
    //分页
    @Override
    public List<SmbmsUser> queryList(String username, int userRole, int currentPageNo, int pageSize) throws Exception {
        return smbmsUserDao.queryUserByUserName(username, userRole, currentPageNo, pageSize);
    }
    //获取总数量
    @Override
    public int getSmbmsUserCount(String username, int userRole) throws Exception
    {
        return smbmsUserDao.getSmbmsUserCount(username, userRole);
    }

    //通过id查询所有信息
    @Override
    public SmbmsUser queryUserById(Long id) throws Exception {
        return smbmsUserDao.queryUserById(id);
    }

    //修改操作
    @Override
    public int updateUser(SmbmsUser smbmsUser) throws Exception {
        return smbmsUserDao.updateUser(smbmsUser);
    }

    //增加
    @Override
    public int addUser(SmbmsUser smbmsUser) throws Exception {
        return smbmsUserDao.addUser(smbmsUser);
    }

    //根据id查询
    @Override
    public SmbmsUser queryUserByUserCode(String userCode) throws Exception {
        return smbmsUserDao.queryUserByUserCode(userCode);
    }

    //删除
    @Override
    public int deleteUser(Long id) throws Exception {
        return smbmsUserDao.deleteUser(id);
    }

    @Override
    public int updatePassword(SmbmsUser smbmsUser) throws Exception {
        return smbmsUserDao.updatePassword(smbmsUser);
    }


}

//2021.01.12
//    //查询所有并支持模糊查询
//    @Override
//    public List<SmbmsUser> queryList(String username, int userRole) throws
//            Exception {
//        return smbmsUserDao.queryUserByUserName(username, userRole);
//    }
//
//    //分页
//    @Override
//    public List<SmbmsUser> queryUser(int currentPageNo, int pageSize) throws
//            Exception {
//        return smbmsUserDao.queryList(currentPageNo, pageSize);
//    }
//
//    //总个数
//    @Override
//    public int getSmbmsUserCount() throws Exception {
//        return smbmsUserDao.getSmbmsUserCount();
//    }
//2021.01.11
//    //查询所有并支持模糊查询
//    @Override
//    public List<SmbmsUser> queryList(String username) throws Exception {
//        return smbmsUserDao.queryUserByUserName(username);
//    }

//    @Override
//    public List<SmbmsUser> queryUser() throws Exception {
//        return smbmsUserDao.queryList();
//    }
//
//
//    //通过用户名进行模糊查询
//    @Override
//    public List<SmbmsUser> queryUserByUserName(String username) throws Exception {
//        return smbmsUserDao.queryUserByUserName(username);
//    }



